import Form from "./form"
import Drawn from "./drawn"
import TableComponent from './table-component'
import ComposePage from "./compose-page"
import FormDisplayElement from "./form-display-element"

import CloudFn from "./cloudFn"




export default (request) => ({
  ...Form(request),
  ...Drawn(request),
  ...TableComponent(request),
  ...ComposePage(request),
  ...FormDisplayElement(request),
  ...CloudFn(request),
  // 查询字典列表数据
  getDicCode: (code, params) =>
    request(`/sys/dict/getDictItems/${code}`, params),
  /** 获取process 列表 */
  getProcessManageTableList: (params) =>
    request({
      url: "/activiti/models/list",
      method: "get",
      params
    }),
  /** 根据Id 获取process xml 数据 */
  getFlowByModelId: (parameter) =>
    request({
      // 根据modelId查询流程数据
      url: "/activiti/flow/getFlowByModelId",
      method: "get",
      params: parameter
    }),
  saveFlow: (parameter) =>
    request({
      // 保存流程
      url: "/activiti/flow/saveFlow",
      method: "post",
      data: parameter
    }),
  /** 新增process  */
  saveProcess: (data) =>
    request({
      url: "/activiti/models/save",
      method: "post",
      data
    }),
  /** 编辑process */
  editProcess: (data) =>
    request({
      url: "/activiti/models/save",
      method: "post",
      data
    }),

  // 查询全部数据库
  queryAllDB: (data) =>
    request({
      url: "/onlcode/database/queryDatabaseList",
      method: "get",
      data
    }),

  // 根据数据库名查询表
  queryTableByDatabase: (params) =>
    request({
      url: "/onlcode/table/queryTableByDb",
      method: "get",
      params
    }),

  // 根据表查询所有字段
  queryFieldsByTable: (params) =>
    request({
      url: "/onlcode/table/getTableById",
      method: "get",
      params
    }),

  // 保存表单 onlcode/form/saveOrUpdate
  saveForm: (data) =>
    request({
      url: "/onlcode/form/saveOrUpdate",
      method: "post",
      data
    }),

  // 查询分夜表单信息
  queryFormByPage: (data) =>
    request({
      url: `/onlcode/form/queryByPage?pageNo=${data.pageNo}&pageSize=${data.pageSize}`,
      method: "post",
      data
    }),

  // 根据id查询表单信息
  // queryFormById: (params) =>
  //   request({
  //     url: "/onlcode/form/getFormById",
  //     method: "get",
  //     params,
  //   }),

  // 数据库查询
  queryDBInfoByPage: (params) =>
    request({
      url: "/onlcode/database/queryByPage",
      method: "get",
      params
    }),

  // 数据库新增编辑
  saveOrUpdateDb: (data) =>
    request({
      url: "/onlcode/database/saveOrUpdate",
      method: "post",
      data
    }),
  // 查询全部数据库
  queryAllDbList: (data) =>
    request({
      url: "/onlcode/database/saveOrUpdate",
      method: "post",
      data
    }),
  // 表单测试数据保存
  onlineTestSave: (data) =>
    request({
      url: "/onlcode/form/form/" + data.formId,
      method: "post",
      data
    }),
  // 表单测试数据编辑
  onlineTestUpdate: (data) =>
    request({
      url: "/onlcode/form/form/" + data.formId,
      method: "put",
      data
    }),
  // 表分页查询
  queryTableByPage: (params) =>
    request({
      url: "/onlcode/table/queryByPage",
      method: "get",
      params
    }),
  // table新增编辑
  saveOrUpdateTable: (data) =>
    request({
      url: "/onlcode/table/saveOrUpdate",
      method: "post",
      data
    }),

  // 同步数据库
  // http://106.14.107.173/yly-common/onlcode/table/doDbSynch/80ed300fe9d83bcd2288e9e432534058/normal
  syncDb: (id) =>
    request({
      url: "/onlcode/table/doDbSynch/" + id + "/normal",
      method: "post"
    }),

  // 发布表单
  punishFormToServer: (data) =>
    request({
      url: "/onlcode/form/publishFormProject",
      method: "post",
      data
    }),
  // 发布表格页面
  publishProjectToServer: (data) =>
    request({
      url: "/onlcode/page/publishProject",
      method: "post",
      data
    }),
  // 获取工程信息
  getProjectInfo: (params) =>
    request({
      url: "/onlcode/project/listAll",
      method: "get",
      params
    }),
  getVersionById: (params) =>
    request({
      url: "/onlcode/formCodes/queryFormPublishVersion",
      method: "get",
      params
    }),

  // 根据tableId获取按钮表单信息
  getButtonListByTableId: (params) =>
    request({
      url: "/onlcode/form/queryButtonFormByTableId",
      method: "get",
      params
    }),

  // 根据formId 查询Columns 信息
  getColumnsByFormId: (params) =>
    request({
      url: "/onlcode/form/queryFormTemplateParams",
      method: "get",
      params
    }),

  // 保存和生成表单的文件代码
  saveGenerateCode: (data) =>
    request({
      url: "/onlcode/form/publishForm",
      method: "post",
      data
    }),
  // 保存和生成表格的文件代码
  saveGeneratePageTableCode: (data) =>
    request({
      url: "/onlcode/page/publishPage",
      method: "post",
      data
    }),
  // 根据id获取在线测试按钮信息
  getOnlineButtonConfig: (params) =>
    request({
      url: "/onlcode/form/getFormButtonById",
      method: "get",
      params
    }),
  // 获取版本发布 按钮信息
  getListFormButtonsVersionPublicConfig: (data) =>
    request({
      url: "/onlcode/formCodes/batchQueryFormPublishInfo",
      method: "post",
      data
    }),
  //
  getFormFieldDefaultVal: (data) =>
    request({
      url: "/onlcode/form/queryFormFieldDefValOptions",
      method: "post",
      data
    }),
  // 查询已存在的Memu
  getExitPublishMenuItem: (data) =>
    request({
      url: "/onlcode/form/queryMenuByAppFormId",
      method: "post",
      data
    }),
  getPublishMenuTree: (data) =>
    request({
      url: "/onlcode/project/queryMenuTreeByAppId",
      method: "post",
      data
    }),
  // 获取角色所对应的树
  getRoleMenuTree: (roleId) =>
    request({
      url: "/onlcode/bifrost/appmenu/new/menuTreeData?roleId=" + roleId,
      method: "get"
    }),
  // 获取没有下级所对应的组织树
  getOrgNoChildMenuTree: (orgId) =>
    request({
      url: "/onlcode/bifrost/org/treeDataExcludeChild?excludeId=" + orgId,
      method: "get"
    }),
  getUserRoleList :(userId) =>
    request({
      url: "/onlcode/bifrost/role/selectBifrostRoleByUserId?userId=" + userId,
      method: "get"
    }),
  // 保存用户最新角色
  saveUserRoleList :(data) =>
    request({
      url: "/onlcode/bifrost/role/addUserRole",
      method: "post",
      data
    }),
  // 获取岗位树
  getJobData: (data) =>
    request({
      url: "/onlcode/bifrost/post/choosePost",
      method: "post",
      data
    }),
  // 获取用户组织树
  getOrgTreeData: (data) =>
    request({
      url: "/onlcode/bifrost/org/treeData",
      method: "get"
    }),

  // 获表格组件列表
  getPageFragList: (data) =>
    request({
      url: "/onlcode/page/queryPageComponentList",
      method: "post",
      data
    }),
  // 根据id 获取page信息
  getPageInfoById: (id) =>
    request({
      url: "/onlcode/page/getPageById?id="+ id,
      method: "get"
    })
  // 根据id 复制一条表单数据
  // copyFormData: (data) =>
  // request({
  //   url: "/onlcode/form/copyForm",
  //   method: "post",
  //     data
  // }),
})
